#coding:utf-8
from alipay import AliPay
import time,os,sys,json
from app import db
from app.home import home
from flask import request, jsonify,session,g,current_app
from app.models import Article
from response_code import RET
from app.func.gengerate_order_id import generate_order_id


#--------------------------首页说明前端接口------------------------------------
@home.route("/index",methods=["GET"])
def index():
    indextips_sort=request.args.get("tips_sort")     #分类
    #分类
    if not indextips_sort:
        current_app.logger.error(sys._getframe().f_code.co_name)
        return jsonify(code=RET.PARAMERR,msg="参数错误")
    try:
        tips_data = db.session.query(Article.id,Article.title,Article.content).filter(Article.title==indextips_sort).first()
        # print(arc_data)
    except:
        current_app.logger.error(sys._getframe().f_code.co_name)
        return jsonify(code=RET.OK,msg="数据库查询失败",data="")

    current_app.logger.error(sys._getframe().f_code.co_name)
    return jsonify(code=RET.OK,msg="获取首页数据成功",tips_data=tips_data)
#--------------------------售后说明前端接口------------------------------------
@home.route("/shouhou",methods=["get"])
def shouhou():
    arc_sort=request.args.get("arc_sort")     #分类
    # print(arc_sort)
    if not arc_sort:
        current_app.logger.error(sys._getframe().f_code.co_name)
        return jsonify(code=RET.PARAMERR,msg="参数错误")
    try:
        arc_data = db.session.query(Article.id,Article.title,Article.content).filter(Article.sort==arc_sort).first()
        # print(arc_data)
    except:
        current_app.logger.error(sys._getframe().f_code.co_name)
        return jsonify(code=RET.OK,msg="数据库查询失败",data="")
    current_app.logger.error(sys._getframe().f_code.co_name)
    return jsonify(code=RET.OK,msg="获取首页数据成功",data=arc_data)




















